package org.dromara.xhlj.system.controller;

import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.system.domain.vo.SysOssUploadVo;
import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.xhlj.system.service.IXhljActivityService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * xhlj-gn-活动
 *
 * @author yf
 * @date 2024-07-24
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/xhlj/activity")
public class XhljActivityController {
    private final IXhljActivityService xhljActivityService;

    /**
     * 获取海报
     *
     * @param activityId 活动id
     * @return poster
     */
    @GetMapping("/poster/{activityId}")
    public R<SysOssUploadVo> poster(@PathVariable Integer activityId) throws Exception {
        SysOssVo oss = xhljActivityService.poster(activityId);
        SysOssUploadVo uploadVo = new SysOssUploadVo();
        uploadVo.setUrl(oss.getUrl());
        uploadVo.setFileName(oss.getOriginalName());
        uploadVo.setOssId(oss.getOssId().toString());
        return R.ok(uploadVo);
    }
}
